package com.wondersgroup.framework.sample.component.demoform.action;

import java.util.Date;

import com.wondersgroup.framework.core.web.struts2.action.BaseAjaxAction;
import com.wondersgroup.framework.core.web.vo.VOUtils;
import com.wondersgroup.framework.core5.model.vo.ValueObject;
import com.wondersgroup.framework.sample.component.demoform.vo.DateVO;
import com.wondersgroup.framework.sample.component.demoform.vs.DemoVS;
import com.wondersgroup.wssip.util.DateTools;
import com.wondersgroup.wssip.util.RequestUtils;

public class DateAction extends BaseAjaxAction {

	private DemoVS demoVS;

	private DateVO dateVO = new DateVO();

	public DemoVS getDemoVS() {
		return demoVS;
	}

	public void setDemoVS(DemoVS demoVS) {
		this.demoVS = demoVS;
	}

	public DateVO getDateVO() {
		return dateVO;
	}

	public void setDateVO(DateVO dateVO) {
		this.dateVO = dateVO;
	}

	@Override
	public ValueObject getValueObject() {
		return this.dateVO;
	}

	@Override
	public String operate() {
		String result = prefix + suffex;
		return result;
	}

	public String loadFormWithDate() {
		DateVO vo = new DateVO();
		vo.setDate1("20161011");
		vo.setDate2("20161212");
		vo.setDate3("20161213");
		vo.setDate4("20160114");

		vo.setMonth1("201602");
		vo.setMonth2("2016年03月");
		vo.setMonth3("201604");

		vo.setTime1("12:12:12");
		vo.setTime2("12:12");

		vo.setDateTime1(DateTools.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		vo.setDateTime2(DateTools.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		vo.setDateTime3(DateTools.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
		String json = prefix + VOUtils.getJsonData(vo) + suffex;
		createJSonData(json);
		return AJAX;
	}

	public String submitFormWithDate() {
		this.logger.error("date1=" + dateVO.getDate1());
		this.logger.error("date2=" + dateVO.getDate2());
		this.logger.error("date3=" + dateVO.getDate3());
		this.logger.error("date4=" + dateVO.getDate4());

		this.logger.error("month1=" + dateVO.getMonth1());
		this.logger.error("month2=" + dateVO.getMonth2());
		this.logger.error("month3=" + dateVO.getMonth3());

		this.logger.error("time1=" + dateVO.getTime1());
		this.logger.error("time2=" + dateVO.getTime2());

		this.logger.error("dateTime1=" + dateVO.getDateTime1());
		this.logger.error("dateTime2=" + dateVO.getDateTime2());
		this.logger.error("dateTime3=" + dateVO.getDateTime3());
		createJSonData(prefix + suffex);
		return AJAX;
	}
}
